<template>
	<view>
		<view style="position: fixed;z-index: 2;">
			<view style="margin-bottom: 30rpx;height: 270rpx;">
				<view style="width: 200rpx;height: 200rpx;margin: 20rpx 0rpx 0 50rpx;float: left;">
					<image :src="get_img+sys.pay_icon" style="width: 200rpx;height: 180rpx;"></image>
				</view>
				<view style="float: right;width: 500rpx;height: 200rpx;margin-top: 20rpx;">
					<view style="margin-left: 10rpx;" class="company_name">{{sys.cpy_name}}</view>
					<view style="height: 200rpx;">
						<view class="company_image">
							<image :src="get_img+'sys/icon/renzheng.png'" style="width: 35rpx;
		height: 35rpx;margin: 20rpx 0rpx 0 10rpx;"></image>
						</view>
						<view style="margin-top: -53rpx;margin-left: 60rpx;font-size: 35rpx;">认证企业</view>
					</view>
				</view>
			</view>
			<view style="width: 720rpx;margin:0 20rpx 0 20rpx;">
				<u--input type="digit" placeholder="消费金额" border="surround" suffixIcon="rmb" :customStyle="styles" v-model="price"></u--input>
			</view>
			<view style="float: right;margin-top: 30rpx;font-size: 50rpx;margin-left: -200rpx;">
				<view style="margin-right: 200rpx;font-size: 40rpx;">实付:</view>
				<view>
					<view style="margin: -43rpx 0 0 120rpx;">
						<u-icon name="rmb" color="red" size="35rpx"></u-icon>
					</view>
					<view style="margin: -55rpx 10rpx 0 160rpx;width: auto;">{{price}}</view>
				</view>
			</view>
			<view style="margin: 100rpx 20rpx 0 0;">
				<u-button type="error" :customStyle="stylese" @click="get_pay">立即支付</u-button>
			</view>
		</view>
		<!-- <view>
			<u-popup :show="!infor.phone" @close="close" :round="10" mode="center">
				<button class="book_img" open-type="getPhoneNumber"  @getphonenumber="getphone" :style="'background-image: url('+get_img+sys.pay_tel_icon+');'" style="background-repeat: no-repeat;background-size: 100% 100%;"></button>
			</u-popup>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				styles: {
					width: "650rpx",
					height: "90rpx",
					backgroundColor: "#F4F4F4"
				},
				stylese: {
					width: "600rpx",
				},
				price: "0",
				show: false,
				infor: "",
				sys:{},
				get_img: this.$get_img,
			}
		},
		onLoad() {
			this.infor = uni.getStorageSync("infor")
			// console.log("infor.phone:", this.infor.phone)
			this.sys = uni.getStorageSync("sys")
			
		},
		methods: {
			get_pay() {
				let that = this
				let data = {
					price: this.price,
				}
				this.$model.post("user/order/create_order", data).then(res => {
					if (res.code == 200) {

						// console.log(res.data)

						uni.requestPayment({
							provider: 'wxpay',
							timeStamp: res.data.timestamp,
							nonceStr: res.data.nonceStr,
							package: res.data.package,
							signType: res.data.signType,
							paySign: res.data.paySign,
							success: function(res) {
								uni.showToast({
									title: "支付成功"
								})
							},
							fail: function(err) {
								uni.showToast({
									title: "支付失败"
								})
							}
						});
					}
				})
			},
				// #ifdef MP-WEIXIN
			getphone(e){
				let that=this;
				uni.login({
				  provider: 'weixin',
				  success: function (loginRes) {
				  
					let data={
						encryptedData:e.detail.encryptedData,
						iv:e.detail.iv,
						code:loginRes.code,
						type:"bind"
					}
					that.$model.post("auth/bind_model",data).then(res=>{
						if(res.code==200){
							that.infor=res.data
							uni.setStorageSync("infor",res.data)
						}
					})
				  }
				});
			},
			// #endif 
			// #ifdef MP-TOUTIAO
			getphone(e){
				let that=this;
				uni.login({
				  provider: 'weixin',
				  success: function (loginRes) {
				  
					let data={
						encryptedData:e.detail.encryptedData,
						iv:e.detail.iv,
						code:loginRes.code,
						type:"bind"
					}
					that.$model.post("auth/bind_model",data).then(res=>{
						if(res.code==200){
							that.infor=res.data
							uni.setStorageSync("infor",res.data)
						}
					})
				  }
				});
			},
			// #endif 
			close() {
				this.show=false
			}
		}
	}
</script>

<style>
.book_img{
		height: 480rpx;
		width: 500rpx;
	
		border-radius: 10px;
		background-size: 100% 100%;
		background-color: rgba(255, 255, 255, 0.3);
	}

</style>
